package main

import (
	"fmt"
	"os"

	crypt "github.com/amoghe/go-crypt"
)

func IsFile(path string) (bool, error) {
	fi, err := os.Stat(path)
	if err != nil {
		return false, err
	}
	return !fi.IsDir(), nil
}

func CheckCrypt(textStr, salt, passStr string) (bool, error) {
	oneStr, err := crypt.Crypt(textStr, salt)
	if err != nil {
		return false, fmt.Errorf("加密密码出错<pass:%s salt:%s>：%s", textStr, salt, err.Error())
	}
	if oneStr == passStr {
		return true, nil
	}
	return false, nil
}
